<?php

require_once("MyWorkouts/Model/MyWorkoutName.php");
require_once("MyWorkouts/Model/MyWorkoutDescription.php");

class MyWorkout
{
	/**
	*@var int 
	**/
	private $id;
	/**
	*@var string
	**/	
	private $name;
	/**
	*@var int  
	**/
	private $userID;
	/**
	*@var string
	**/
	private $description;

	/**
	*@param MyWorkoutName
	*@param MyWorkoutDescription
	*@param int
	*@param int
	**/
	private function __construct(MyWorkoutName $name, MyWorkoutDescription $description, $id=null, $userID = null)
	{
		$this->name = $name;
		$this->description = $description;

		if($id != null)
		{
			$this->id = $id;
		}
		if($userID != null)
		{
			$this->userID = $userID;
		}
	}

	/**
	*@param MyWorkoutName
	*@param MyWorkoutDescription
	*@return MyWorkout
	**/
	public static function createNewWorkout($name, $description)
	{	
		return new MyWorkout(new MyWorkoutName($name), new MyWorkoutDescription($description));
	}

	/**
	*@param int
	*@param MyWorkoutName
	*@param MyWorkoutDescription
	*@param int
	*@return MyWorkout
	**/
	public static function createWorkoutFromDatabase($id, $name, $description, $userID)
	{
		return new MyWorkout(new MyWorkoutName($name), new MyWorkoutDescription($description), $id, $userID);
	}

	/**
	*@return int
	**/
	public function getID()
	{
		return $this->id;
	}
	/**
	*@return int
	**/
	public function getUserID()
	{
		return $this->userID;
	}

	/**
	*@return string
	**/
	public function getName()
	{
		return $this->name->getWorkoutName();
	}

	/**
	*@return string
	**/
	public function getDescription()
	{
		return $this->description->getWorkoutDescription();
	}

	/**
	*@param int
	*@return boolean
	**/
	public function compareUserID($otherUserId)
	{ 
		if($otherUserId == $this->getUserID())
		{
			return true;
		}
		return false;

	}

}